//
//  HMStatusBottomView.swift
//  大深圳微博01
//
//  Created by shenzhenIOS on 16/4/14.
//  Copyright © 2016年 shenzhenIOS. All rights reserved.
//

import UIKit

class HMStatusBottomView: UIView {
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        
//        backgroundColor = UIColor.brownColor()
        prepareUI()
    }
    
    private func prepareUI() {
        // 1.添加子控件
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(likeButton)
        addSubview(separatorViewFirst)
        addSubview(separatorViewSecond)
        
        // 2.添加约束
        // 转发按钮
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.leading.top.bottom.equalTo(self)
        }
        
        // 评论按钮
        commentButton.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(retweetButton.snp_trailing)
            make.top.bottom.equalTo(self)
            
            make.width.equalTo(retweetButton)
        }
        
        // 赞按钮
        likeButton.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(commentButton.snp_trailing)
            make.top.trailing.bottom.equalTo(self)
            
            make.width.equalTo(retweetButton)
        }
        
        // 分割视图1
        separatorViewFirst.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(retweetButton)
            make.centerX.equalTo(retweetButton.snp_trailing)
        }
        
        // 分割视图2
        separatorViewSecond.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(commentButton)
            make.centerX.equalTo(commentButton.snp_trailing)
        }
    }

    // MARK: - 懒加载
    /// 转发按钮
    private lazy var retweetButton: UIButton = UIButton(image: "timeline_icon_retweet", title: "转发")
//    private lazy var retweetButton: UIButton = {
//        let button = UIButton()
//        
//        // 设置按钮背景图片
//        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
//        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
//        
//        // 设置按钮图片
//        button.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
//        
//        // 设置按钮标题
//        button.setTitle("转发", forState: UIControlState.Normal)
//        
//        return button
//    }()
    
    /// 评论按钮
    private lazy var commentButton: UIButton = UIButton(image: "timeline_icon_comment", title: "评论")
//    private lazy var commentButton: UIButton = {
//        let button = UIButton()
//        
//        // 设置按钮背景图片
//        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
//        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
//        
//        // 设置按钮图片
//        button.setImage(UIImage(named: "timeline_icon_comment"), forState: UIControlState.Normal)
//        
//        // 设置按钮标题
//        button.setTitle("评论", forState: UIControlState.Normal)
//        
//        return button
//    }()
    
    /// 赞
    private lazy var likeButton: UIButton = UIButton(image: "timeline_icon_unlike", title: "赞")
//    private lazy var likeButton: UIButton = {
//        let button = UIButton()
//        
//        // 设置按钮背景图片
//        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
//        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
//        
//        // 设置按钮图片
//        button.setImage(UIImage(named: "timeline_icon_unlike"), forState: UIControlState.Normal)
//        
//        // 设置按钮标题
//        button.setTitle("赞", forState: UIControlState.Normal)
//        
//        return button
//    }()
    
    /// 分割线1
    private lazy var separatorViewFirst: UIImageView = UIImageView(imageNamed: "timeline_card_bottom_line")
    
    /// 分割线2
    private lazy var separatorViewSecond: UIImageView = UIImageView(imageNamed: "timeline_card_bottom_line")
}
